using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Net.Mail;
using System.Collections.Generic;
using System.Text;

namespace B2C.Utilities
{
    /// <summary>
    /// Utility class for sending email
    /// Design and Architecture: Mohammad Ashraful Alam [joy_csharp@hotmail.com]
    /// </summary>
    public sealed class Emailer
    {
        private Emailer() { }


        

        public static bool SendMail(String to, String from, string fromName, String subject, String body)
        {
            SmtpClient smtpClient = new SmtpClient();
            MailMessage message = new MailMessage();

            try
            {
                MailAddress fromAddress = new MailAddress(from, fromName);
                //mail server
                smtpClient.Host = "smtp.emailsrvr.com";
                smtpClient.Credentials = new System.Net.NetworkCredential("noreply@desme.com", "d3sme0nline");

                //From address will be given as a MailAddress Object
                message.From = fromAddress;

                // To address collection of MailAddress
                message.To.Add(to);
                message.Subject = subject;

                // CC and BCC optional
                //message.Bcc.Add(new MailAddress("joy_csharp@yahoo.com"));

                //Body can be Html or text format
                //Specify true if it  is html message
                message.IsBodyHtml = true;

                // Message body content
                message.Body = body;

                //Send SMTP mail
                smtpClient.Send(message);

                //lblStatus.Text = "Email successfully sent.";
            }
            catch (SmtpException smtpEx)
            {
               return false;
            }
            catch (Exception ex)
            {
               return false;
            }
            return true;
        }

       
    }
}